class Permission {
    constructor() {
        this.replace = false;
        this.restrict = 'A';
        this.scope={};
    }
    controller($scope, $timeout) {
        'ngInject'
        $scope._timeout = $timeout;
    }
    link(scope, el, attr) {
        let hideEl=()=>{
            if (!scope.$root.permission||!scope.$root.permission.length || scope.$root.permission.indexOf(attr.permission) < 0) {
                    el.addClass('ng-hide');
            }else{
                 el.removeClass('ng-hide');
            }
        }
        scope.$on('$permission',hideEl);
        hideEl();
    }

    static factory() {
        return new Permission();
    }
}

export default Permission;